package com.tanguy.user.ui.me.adapter

import android.widget.TextView
import cn.sinata.xldutils_kotlin.adapter.BaseRecyclerAdapter
import cn.sinata.xldutils_kotlin.adapter.util.ViewHolder
import com.tanguy.user.R
import com.tanguy.user.bean.Price
import org.jetbrains.anko.backgroundDrawable
import org.jetbrains.anko.textColor
import java.util.*

/**
 * Created by dab on 2017/10/10 0010 10:20
 */
/**
 * 我的钱包选择金额
 * Created by zhangyujiu on 2017/8/30.
 */
class SelectPriceAdapter(mData: ArrayList<Price>) : BaseRecyclerAdapter< Price>(mData, R.layout.item_select_price) {
    var selectPrice = 0
    override fun onBind(holder: ViewHolder, position: Int, data: Price) {
        val tv_price = holder.bind<TextView>(R.id.tv_price)
        tv_price.text = String.format(Locale.CHINA, "￥%d", data.price)
        if (selectPrice == position) {
            tv_price.backgroundDrawable = context.resources?.getDrawable(R.drawable.corner_price_press)
            tv_price.textColor = context.resources?.getColor(R.color.color_fb408e)!!
        } else {
            tv_price.backgroundDrawable = context.resources?.getDrawable(R.drawable.corner_price_normal)
            tv_price.textColor = context.resources?.getColor(R.color.textColor)!!
        }
    }
}